<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <!-- [js] 写一个方法把0和1互转（0置1，1置0） -->
  <script>
    const reverse = num=>+!num

    直接异或操作就行了

const convert = num => num^1;
convert(0); // 1
convert(1); // 0
  </script>
</body>
</html>